const mysql = require('mysql2/promise');
const fs = require('fs').promises;
const path = require('path');

// 数据库配置 - 请根据实际情况修改
const dbConfig = {
  host: 'localhost',
  user: 'root', 
  password: 'your_password',
  database: 'computer_guide',
  charset: 'utf8mb4'
};

async function runMigration() {
  let connection;
  
  try {
    console.log('🔗 连接数据库...');
    connection = await mysql.createConnection(dbConfig);
    
    console.log('📖 读取新的迁移文件...');
    const migrationPath = path.join(__dirname, 'database', 'migrations', 'update_user_location_fields.sql');
    const migrationSQL = await fs.readFile(migrationPath, 'utf8');
    
    console.log('🔄 执行迁移...');
    console.log('SQL:', migrationSQL);
    
    await connection.execute(migrationSQL);
    

  } catch (error) {

  } finally {
    if (connection) {
      await connection.end();
    
    }
  }
}

runMigration(); 